package models.mappers;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import models.RegionLevel;
import models.RegionLevelRelation;
import models.RegionLevel;
import vos.RegionLevelRelationVo;
import vos.RegionLevelSeachVo;

public interface RegionLevelMapper {
	/**
	 * 获取城市等级下拉框
	 *
	 * @Title: getCombobox 
	 * @return
	 * @return: List<RegionLevel>
	 */
	@Select("select levelid,levelname from region_level"
			+ " where isflag=false")
	List<RegionLevel> getCombobox();
	/**
	 * 统计城市等级
	 *
	 * @Title: countRegionLevel 
	 * @return
	 * @return: long
	 */
	long countRegionLevel();
	/**
	 * 获取城市等级列表
	 *
	 * @Title: listRegionLevel 
	 * @param vo
	 * @return
	 * @return: List<RegionVo>
	 */
	List<RegionLevel> listRegionLevel(RegionLevelSeachVo vo);
	/**
	 * 批量启用城市等级
	 *
	 * @Title: betchEnable 
	 * @param listid 城市等级id列表
	 * @return
	 * @return: Boolean
	 */
	void betchEnable(Map<String, Object> map);
	/**
	 * 批量停用城市等级
	 *
	 * @Title: betchEnable 
	 * @param listid 城市等级id列表
	 * @return
	 * @return: Boolean
	 */
	void betchDisable(Map<String, Object> map);
	/**
	 * 批量删除城市等级
	 *
	 * @Title: betchDel 
	 * @param map
	 * @return: void
	 */
	void betchDel(Map<String, List<String>> map);
	/**
	 * 根据id删除城市等级
	 *
	 * @Title: delRegionLevel 
	 * @param id
	 * @return: void
	 */
	@Delete("delete from "
			+ RegionLevel.TABLE_NAME
			+" where levelid=#{id}")
	void delRegionLevel(String id);
	/**
	 * 根据id判断是否存在该城市等级
	 *
	 * @Title: checkCode 
	 * @param levelid
	 * @return
	 * @return: String
	 */
	@Select("select 1 from "
			+ RegionLevel.TABLE_NAME
			+" where levelid=#{levelid}")
	String checkCode(String levelid);
	/**
	 * 根据id获取城市等级信息
	 *
	 * @Title: getById 
	 * @param levelid 城市等级id
	 * @return
	 * @return: RegionLevel
	 */
	@Select("select * from "
			+ RegionLevel.TABLE_NAME
			+" where levelid=#{levelid}")
	RegionLevel getById(Long levelid);
	/**
	 * 保存城市等级信息
	 *
	 * @Title: saveRegionLevel 
	 * @param device
	 * @return: void
	 */
	@Insert("insert into "
			+ RegionLevel.TABLE_NAME
			+" (levelid,levelname,isflag,createtime,createname,remark) values"
			+ "(#{levelid},#{levelname},#{isflag},#{createtime},#{createname},#{remark})")
	void saveRegionLevel(RegionLevel device);
	/**
	 * 更新城市等级信息
	 *
	 * @Title: updateRegionLevel 
	 * @param device
	 * @return: void
	 */
	@Update("update "
			+ RegionLevel.TABLE_NAME
			+" set levelname=#{levelname},"
			+ "isflag=#{isflag},modifyname=#{modifyname},modifytime=#{modifytime},remark=#{remark}"
			+ " where levelid=#{levelid}")
	void updateRegionLevel(RegionLevel level);
	/**
	 * 导出为excel
	 *
	 * @Title: exportXls 
	 * @param vo
	 * @return
	 * @return: List<RegionLevel>
	 */
	List<RegionLevel> exportXls(RegionLevelSeachVo vo);
	/**
	 * 根据等级id统计对应关系
	 *
	 * @Title: getByLevel 
	 * @param id
	 * @return
	 * @return: long
	 */
	@Select("select * from region_level_relation where levelid=#{id} limit 1")
	RegionLevelRelation getByLevel(String id);
	/**
	 * 根据地区id获取等级信息
	 *
	 * @Title: getByRegionId 
	 * @param id
	 * @return
	 * @return: RegionLevelRelationVo
	 */
	@Select("select * from regin_level_relation_view where id=#{id}")
	RegionLevelRelationVo getByRegionId(String id);
}
